package com.ruoyi.project.mahjong.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.mahjong.domain.TParagraph;
import com.ruoyi.project.mahjong.service.ITParagraphService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 时间段收费Controller
 * 
 * @author ruoyi
 * @date 2023-10-07
 */
@RestController
@RequestMapping("/mahjong/paragraph")
public class TParagraphController extends BaseController
{
    @Autowired
    private ITParagraphService tParagraphService;

    /**
     * 查询时间段收费列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:list')")
    @GetMapping("/list")
    public TableDataInfo list(TParagraph tParagraph)
    {
        startPage();
        List<TParagraph> list = tParagraphService.selectTParagraphList(tParagraph);
        return getDataTable(list);
    }

    /**
     * 导出时间段收费列表
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:export')")
    @Log(title = "时间段收费", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TParagraph tParagraph)
    {
        List<TParagraph> list = tParagraphService.selectTParagraphList(tParagraph);
        ExcelUtil<TParagraph> util = new ExcelUtil<TParagraph>(TParagraph.class);
        return util.exportExcel(list, "paragraph");
    }

    /**
     * 获取时间段收费详细信息
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tParagraphService.selectTParagraphById(id));
    }

    /**
     * 新增时间段收费
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:add')")
    @Log(title = "时间段收费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TParagraph tParagraph)
    {
        return toAjax(tParagraphService.insertTParagraph(tParagraph));
    }

    /**
     * 修改时间段收费
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:edit')")
    @Log(title = "时间段收费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TParagraph tParagraph)
    {
        return toAjax(tParagraphService.updateTParagraph(tParagraph));
    }

    /**
     * 删除时间段收费
     */
    @PreAuthorize("@ss.hasPermi('mahjong:paragraph:remove')")
    @Log(title = "时间段收费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tParagraphService.deleteTParagraphByIds(ids));
    }
}
